// pages/orderDetail/orderDetail.js
import {
  unified_order
} from '../../utils/api.js'
import {
  MD5
} from '../../utils/MD5.js'

var app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    list: [],//物流详情列表 
    items: [],
    addr: {},
    orderInfo: {},
    goodsInfo: []
  },

  /**
   * 生命周期函数--监听页面加载
   */
  // 复制到剪贴版
  copyToCli: function (e) {
    wx.setClipboardData({
      data: e.currentTarget.dataset.content,
      success(res) {
        app.showTipMsg('复制到剪贴板')
      }
    })
  },
  onLoad: function (options) {
    var id = options.id;
    var that = this;
    var url2 = '/mall/get_express_data';
    var params2 = {
      id: id
    };
    app.HttpPostSend(url2, params2, function (res) {
      // console.log(res)
      if (res.code <= 0) {
        app.showTipMsg(res.msg);
      } else {
        if (res.data) {
          var orderInfo = res.data.orderInfo;

          var goodsInfo = res.data.goodsInfo;
          for (var i = 0; i < goodsInfo.length; i++) {
            goodsInfo[i].title = goodsInfo[i].title.slice(0, 12) + "...";
          }

          that.setData({
            orderInfo: orderInfo,
            goodsInfo: goodsInfo,
            spec_price_name: res.data.spec_price_name,
            express: res.data.express
          })
        }
      }
    });
  },
  //点击进入详情页面
  bindGoodsTap: function (e) {
    var id = e.detail.button_typId;
    var title = e.detail.button_status;
    wx.navigateTo({
      url: '../goodsDetail/goodsDetail?id=' + id + '&title=' + title,
    })
  },

  bindEditTap: function (e) {
    wx.navigateTo({
      url: '../myAddress/myAddress?goodsId=' + this.data.goodsId + '&mount=' + this.data.mount,
    })
  },
 

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },
  toGoodsDetail: function (e) {
    wx.navigateTo({
      url: "/pages/goodsDetail/goodsDetail?id=" + e.currentTarget.dataset.id
    })
  }

  /**
   * 用户点击右上角分享
   */
  // onShareAppMessage: function () {

  // }
})